﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using FluentNHibernate;
using FluentNHibernate.Mapping;
using SimpleServiceBus.Persistence.Domain;
using SimpleServiceBus.Persistence.NHibernate.Mapping.Helpers;

namespace SimpleServiceBus.Persistence.NHibernate.Mapping
{
    public abstract class SsbEntityMap<TEntity> : ClassMap<SsbEntity>, IMapGenerator
        where TEntity:SsbEntity
    {
        protected SsbEntityMap()
        {
            ///I spent 15 or 20 minutes looking for
            ///some guidance on how to select an appropriate
            /// max_lo, but I haven't seen any. However, *every*
            /// sample I saw used 100, so at the risk of following
            /// the rest of the lemmings off of a cliff, I'll
            /// use '100' as well.
            Id(x => x.Id, "Id")
                .GeneratedBy.HiLo("100");
                
        }

        public XmlDocument Generate()
        {
            return CreateMapping(new MappingVisitor());
        }
    }
}
